Conversation
`$ npm test -- test/yodev.test.js --match="yodev*"`
`$ huemul yodev [QUERY]`
Updated comments to include detailed information about the script's functionality, dependencies, configuration, commands, examples, and author.
There was a problem hiding this comment.
Pull request overview
This PR refactors the job search output formatting to improve display in Slack by using Slack's Block Kit API instead of plain text formatting. The changes modernize the user interface and provide a cleaner, more structured presentation of job listings.
- Implements Slack Block Kit formatting with sections, dividers, and context blocks for better visual hierarchy
- Adds fallback formatting for non-Slack platforms to ensure compatibility
- Updates emoji usage in search message and result displays
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const blocks = [ | ||
| { | ||
| type: 'section', | ||
| text: { | ||
| type: 'mrkdwn', | ||
| text: `Encontré ${totalJobs} resultado(s):` | ||
| } | ||
| } | ||
| ] | ||
|
|
||
| if (job.salary) lines.push(`💰 *Sueldo:* ${job.salary}`) | ||
| if (job.type) lines.push(`🧩 *Tipo:* ${job.type}`) | ||
| if (job.source) lines.push(`🛰️ *Fuente:* ${job.source}`) | ||
| limitedJobs.forEach((job) => { | ||
| blocks.push({ type: 'divider' }) | ||
|
|
||
| return lines.join('\n') | ||
| const lines = [`*<${job.url}|${job.title}>*`] | ||
| lines.push(`*Empresa:* ${job.company}`) | ||
| lines.push(`*Ubicación:* ${job.location}`) | ||
| if (job.posted || job.date) lines.push(`*Publicado:* ${job.posted || job.date}`) | ||
| if (job.salary) lines.push(`*Sueldo:* ${job.salary}`) | ||
| if (job.type) lines.push(`*Tipo:* ${job.type}`) | ||
| if (job.source) lines.push(`*Fuente:* ${job.source}`) | ||
|
|
||
| blocks.push({ | ||
| type: 'section', | ||
| text: { | ||
| type: 'mrkdwn', | ||
| text: lines.join('\n') | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| if (viewMoreUrl) { | ||
| messages.push(`\n🔍 ¿Quieres ver más ofertas? Visita: ${viewMoreUrl}`) | ||
| blocks.push({ type: 'divider' }) | ||
| blocks.push({ | ||
| type: 'context', | ||
| elements: [{ | ||
| type: 'mrkdwn', | ||
| text: `¿Quieres ver más ofertas? Visita: <${viewMoreUrl}|yodev.dev>` | ||
| }] | ||
| }) | ||
| } |
There was a problem hiding this comment.
The Slack blocks are being built unconditionally, but they're only used when the platform is Slack. This creates unnecessary computation when the platform is not Slack. Consider moving the blocks construction inside the Slack-specific conditional block (line 107) to avoid building data structures that won't be used in non-Slack environments.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Descripción
Se veía muy feo en Slack, se rediseñó el output.
Ejemplo de comportamiento
$ huemul yodev developer